import axios from 'axios'
import common from './common'
import weui from 'weui.js'

export function saveUserInfo (data, self) {
  let config = {
    headers: {
      'access-token': common.accesstoken,
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }

  let queryUrl = common.api.memberCenter.updateInfo
  let loading = weui.loading('加载中')
  axios.post(queryUrl, data, config).then(function (res) {
    if (res.data.resultMsg === 'success') {
      loading.hide()
      weui.toast('修改成功')
      console.log(self)
      self.$router.go(-1)
    } else {
      loading.hide()
      weui.toast('请求失败')
      console.log(res.data.resultMsg)
    }
  })
}
